<template>
  <div class></div>
</template>
<script>
import axios from "@/utils/requestdp";

export default {
  name: "APImanageHeatPlantzz",
  components: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  mounted() {
    this.watchEvent();
  },
  methods: {
    watchEvent() {
      //先清除定时任务
      if (
        this.$store.state.daping.intervalArr["APImanageHeatPlantzz"] != undefined
      ) {
        clearInterval(
          this.$store.state.daping.intervalArr["APImanageHeatPlantzz"][0].interval
        );
      }
      this.loadData();
      let interval = setInterval(() => {
        this.loadData();
      }, this.$root.setting.data.interval);
      this.$store.state.daping.intervalArr["APImanageHeatPlantzz"] = [
        { interval: interval },
      ];
    },
    loadData() {
      let pidArr20 = [];
      let pidArr8 = [];
      let heatPlantInfoMap = {};

      axios.post("/model/heatPlants", {}).then((res) => {
        let data = res.rows;
        for (var i = 0; i < data.length; i++) {
          if (data[i]["state"] == 1 || data[i]["state"] == "1") {
            //投运
            switch (
              data[i]["sourceType"] //1:外围电厂 2：隔压占 3：热电厂 4：燃气锅炉
            ) {
              case 1:
              case 3:
                pidArr20.push(data[i]["pid"]);
                break;
              case 2:
              case 4:
                if (data[i]["pid"] != "43622") {
                  //【2020-1-20】二马路不需要展示
                  pidArr8.push(data[i]["pid"]);
                }
                break;
            }
          }
        }
        this.$store.state.daping.manageHeatPlantzz = {
          pidArr20: pidArr20,
          pidArr8: pidArr8,
          heatPlantInfoMap: data,
        };
      });
    },
  },
};
</script>
<style lang='scss' scoped>
</style>